package com.bruce.ai.alibaba.agentcard.discovery.model;

import com.fasterxml.jackson.annotation.JsonProperty;
import java.time.Instant;
import java.util.Map;
import java.util.UUID;

/**
 * A2A请求模型，用于Agent间通信
 * 基于Google A2A协议标准设计
 */
public class A2ARequest {
    
    @JsonProperty("id")
    private String id;
    
    @JsonProperty("timestamp")
    private Instant timestamp;
    
    @JsonProperty("source_agent")
    private String sourceAgent;
    
    @JsonProperty("target_agent")
    private String targetAgent;
    
    @JsonProperty("message")
    private String message;
    
    @JsonProperty("message_type")
    private String messageType;
    
    @JsonProperty("metadata")
    private Map<String, Object> metadata;
    
    @JsonProperty("timeout_ms")
    private Long timeoutMs;
    
    @JsonProperty("priority")
    private Priority priority;
    
    public A2ARequest() {
        this.id = UUID.randomUUID().toString();
        this.timestamp = Instant.now();
        this.priority = Priority.NORMAL;
        this.timeoutMs = 30000L; // 默认30秒超时
    }
    
    public A2ARequest(String sourceAgent, String targetAgent, String message) {
        this();
        this.sourceAgent = sourceAgent;
        this.targetAgent = targetAgent;
        this.message = message;
        this.messageType = "text";
    }
    
    // Getters and Setters
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public Instant getTimestamp() {
        return timestamp;
    }
    
    public void setTimestamp(Instant timestamp) {
        this.timestamp = timestamp;
    }
    
    public String getSourceAgent() {
        return sourceAgent;
    }
    
    public void setSourceAgent(String sourceAgent) {
        this.sourceAgent = sourceAgent;
    }
    
    public String getTargetAgent() {
        return targetAgent;
    }
    
    public void setTargetAgent(String targetAgent) {
        this.targetAgent = targetAgent;
    }
    
    public String getMessage() {
        return message;
    }
    
    public void setMessage(String message) {
        this.message = message;
    }
    
    public String getMessageType() {
        return messageType;
    }
    
    public void setMessageType(String messageType) {
        this.messageType = messageType;
    }
    
    public Map<String, Object> getMetadata() {
        return metadata;
    }
    
    public void setMetadata(Map<String, Object> metadata) {
        this.metadata = metadata;
    }
    
    public Long getTimeoutMs() {
        return timeoutMs;
    }
    
    public void setTimeoutMs(Long timeoutMs) {
        this.timeoutMs = timeoutMs;
    }
    
    public Priority getPriority() {
        return priority;
    }
    
    public void setPriority(Priority priority) {
        this.priority = priority;
    }
    
    public enum Priority {
        LOW, NORMAL, HIGH, URGENT
    }
    
    @Override
    public String toString() {
        return "A2ARequest{" +
                "id='" + id + '\'' +
                ", timestamp=" + timestamp +
                ", sourceAgent='" + sourceAgent + '\'' +
                ", targetAgent='" + targetAgent + '\'' +
                ", message='" + message + '\'' +
                ", messageType='" + messageType + '\'' +
                ", priority=" + priority +
                '}';
    }
}